package hive.ch1.test1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MRCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    private final Text keyOut = new Text();
    private final IntWritable valueOut = new IntWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();

        String[] fields = line.split(",");

        keyOut.set(fields[1]);

        context.write(keyOut, valueOut);
    }
}
